<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "shbb_equip".
 *
 * @property integer $id
 * @property string $code
 * @property string $comment
 * @property integer $is_delete
 * @property integer $delete_time
 * @property integer $equip_type_id
 * @property integer $park_id
 * @property integer $land_id
 *
 * @property ShbbEquipType $equipType
 * @property ShbbLand $land
 * @property ShbbPark $park
 */
class Equip extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'shbb_equip';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'is_delete', 'delete_time', 'equip_type_id', 'park_id', 'land_id'], 'integer'],
            [['code', 'comment'], 'string', 'max' => 255],
            [['code'], 'unique'],
            [['code', 'comment'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '设备ID',
            'code' => '设备编号',
            'comment' => '备注',
            'is_delete' => '是否删除',
            'delete_time' => '删除时间',
            'equip_type_id' => '设备类别ID',
            'park_id' => '所属园区',
            'land_id' => '所属地块'
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEquipType()
    {
        return $this->hasOne(Equiptype::className(), ['id' => 'equip_type_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getLand()
    {
        return $this->hasOne(Land::className(), ['id' => 'land_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getPark()
    {
        return $this->hasOne(Park::className(), ['id' => 'park_id']);
    }
}
